%by clq
%%%%%%%%%%%%%%%%%%%%%%%%p=(0.25,0.5,0.75)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%call_in_sequence=[2 2 1 3 3 3 3 3 2 2 1 2 3 3 3 3 1 1 2 1 3 1 2 3 1 1 1 2 3 1 2 3 3 1 2 1 3 3 2 2 2 1 1 2 1 1 2 1]
function figure6(j_all, N)
    figure(6);

    global P 
    P = [.25, .5, .75];
    [best_is, opt_profits, ~, ~, ~] = prop_policy(j_all, N);
    [~, profits_R, ~, ~, ~] = round_robin(j_all, N);

    load('pref_likely');pref=pref_likely; %论文中pref序列未知，给定一个方便比较结果
    %pref = randi([1, 2], 1, N);%另一种决定pref的方法：随机给定
    [~, opt_profits_pref] = prop_pref(j_all, pref);
    [~, profits_RP] = round_robin_pref(j_all, pref);

    n = length(best_is);

    %first draw the expected profit
    yyaxis left;
    plot(1:n,opt_profits,'-');
    hold on;
    plot(1:n,profits_R,'--');
    hold on;
    plot(1:n,opt_profits_pref,'.:');
    hold on; 
    plot(1:n,profits_RP,'.--');
    legend('Proposed Policy','Round Robin','Prop. Policy with Pref.','Round Robin with Pref.','Location','NorthWest')

    %then mark the best slot
    yyaxis right;
    hold on; 
    stem(1:n,best_is,'o:','HandleVisibility','off');
    ylim([0 9])
    yticks([1:8]);
    yticklabels({'1:(2,2,2)','2:(1,0,3)','3:(2,1,2)','4:(1,2,1)','5:(2,0,2)','6:(2,2,1)','7:(0,1,2)','8:(1,1,1)'})

    %at last different labels
    yyaxis left;
    ylim([0 1800]);
    xlim([0 49]);
    ylabel('Expected Profit');
    xlabel('Sequence of patient types');
    xticks([1:48]);
    xticklabels({'2','2','1','3','3','3','3','3','2','2','1','2','3','3','3','3','1','1','2','1','3','1','2','3','1','1','1','2','3','1','2','3','3','1','2','1','3','3','2','2','2','1','1','2','1','1','2','1'});

    %different lines and marks
    hold on;
    line([30,30],[0,1800],'LineWidth',3,'HandleVisibility','off');
    hold on; 
    line([31,31],[0,1800],'LineWidth',3,'HandleVisibility','off');
end